<?php
function generate_cat_url($cat = array()){
    if($cat){
        return '/'.$cat['cat_name'].'-'.$cat['cat_id'].'.chn';
    }else{
        return '/san-pham';
    }

}

function generate_blog_detail_url($blog) {
    return '/blog/' .removeTitle($blog['blo_title']). '-' .$blog['blo_id']. '.html';
}
function generate_product_order_url($product) {
    return '/dat-mua/' .removeTitle($product['pro_name']). '-' .$product['pro_id']. '.html';
}
function generate_service_cat_url($cat) {
    return '/dich-vu/' .removeTitle($cat['cat_name']). '-' .$cat['cat_id']. '/';
}
function generate_service_detail_url($products) {
    return '/dich-vu/' .removeTitle($products['ser_title']). '-' .$products['ser_id']. '.html';
}

function generate_page_detail_url($page) {
    return '/' .removeTitle($page['pag_title']). '-' .$page['pag_id']. '.html';
}

function generate_news_page_url($page) {
    return '/tin-tuc/trang-'.$page.'/';
}

function generate_news_detail_url($news) {
    return '/tin-tuc/' .removeTitle($news['new_title']). '-' .$news['new_id']. '.html';
}

function generate_news_cat_url($news_cat) {
    return '/danh-muc-tin/' .removeTitle($news_cat['cat_name']). '-' .$news_cat['cat_id']. '.html';
}
function removeTitle($string,$keyReplace = "/"){
	 $string = removeSign($string);
	 $string  =  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  =  str_replace(" ","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
?>